﻿require "Common/UtilFunction"
require "Common/BroadcastType"


Util = LuaFramework.Util;
AppConst = LuaFramework.AppConst;
WWW = UnityEngine.WWW;
GameObject = UnityEngine.GameObject;

skillDestDist = 10
skillDestDist2 = 30

LayerName = 
{
	__index = function(t, k)
		rawset(t, k, k)
		return k
	end
}
setmetatable(LayerName, LayerName)


Layer = 
{
	__index = function(t, k)
		local layer = UnityEngine.LayerMask.NameToLayer(k)
		rawset(t, k, layer)
		return layer
	end
}
setmetatable(Layer, Layer)


LayerMask = 
{
	__index = function(t, k)
		local layerMask = bit.lshift(1, UnityEngine.LayerMask.NameToLayer(k))
		rawset(t, k, layerMask)
		return layerMask
	end
}
setmetatable(LayerMask, LayerMask)

AnimNameHash = 
{
	__index = function(t, k)
		local hash = UnityEngine.Animator.StringToHash(k)
		rawset(t, k, hash)
		return hash
	end
}
setmetatable(AnimNameHash, AnimNameHash)



RenderQueueType =
{
	terrain = 1900,
	skill_range = 1901,
	me = 2500,
}


AnimDir =
{
	forward = 0,
	rightward = 1,
	backward = 2,
	leftward = 3,
}

function AnimDir.DegreeNormalize(dirAngle)
	dirAngle = dirAngle % 360
	if dirAngle < 0 then
		dirAngle = dirAngle + 360
	end
	return dirAngle
end

function AnimDir.DegreeNormalize2(dirAngle)
	dirAngle = dirAngle % 360
	if dirAngle >180 then
		dirAngle = dirAngle - 360
	end
	return dirAngle
end


function AnimDir.ConvertDegreeToAnimDir(dirAngle)
	dirAngle = AnimDir.DegreeNormalize(dirAngle)
	return math.floor(((dirAngle + 45) % 360) / 90)
end

function AnimDir.ConvertDegreeToAnimDir2(dirAngle)
	dirAngle = AnimDir.DegreeNormalize(dirAngle)
	return dirAngle > 180 and (dirAngle - 360) or dirAngle
end

AnimState =
{
	none = 0,
	idle = 1,
	run = 2,
	stand = 3,
	walk = 4,
	-- warn = 5,
	skill = 6,
	die = 7,
	hit = 11,
	hitback = 12,
	hitfly= 13,
	down = 14,
	getup = 15,
	getup2 = 16,
	revert = 100,
}


BuffPhase = 
{
	remove = 0,
	add = 1,
}

--require "Common/skill_define"






TutorialType = 
{
	rookie = 7,
	-- new_rookie = 8,
	new_rookie = 9,
}






-- 资源条类型
ResourceType =
{
	GOLD = 1,  -- 金币
	DIAMOND = 2, --钻石
}

ItemQuality =
{
	green = 1,
	blue = 2,
	purple = 3,
	gold = 4,
	orange = 5,
	red = 6,
}




TestAccount = {
	"12345678900",
	"12345678901",
	"12345678902",
	"12345678903",
	"12345678904",
	"12345678905",
}

MaxTurnNum = 20
MaxSP = 100
PetOccupation = {
	Warrior = 1,
	Tank = 2,
	ADC = 3,
	SUP = 4,
}

MapType = {
	World = 1,
	Level = 2,
}

Department ={
	Water = 1,
	Fire = 2,
	Wood = 3,
	Soil = 4,
	Wind = 5,
	Thunder = 6,
}
DrawCardType = {
	Gold = 1,
	GoldFree = 2,
	Diamond = 3,
	DiamondFree = 4,
	FriendPoint = 5,
}

BattleUtype = {
	Arena = 1,
	MapBattle = 2,
	Endless = 3,
	Dungeon = 4,
	Event = 5,
	Hotel = 6,
	GuildBoss = 7,
}
BattleState = {
	readying = 0, -- 正在跑
	showing = 1, -- 正在跑
	delay = 2, -- 正在跑
	going = 3, -- 战斗中
	ending = 4, -- 打斗结束
	over = 5, -- 出弹框了
}
BattleTime = 90
MaxCarNum = 3

Repice = {
	BlueRecipe = 220001,  -- 蓝色配方
	PurpleRecipe = 220002,  -- 紫色配方
	GoldRecipe = 220003,  -- 金色配方
	RedRecipe = 220004,  -- 红色配方
}

TECH_EXP = {
	NortheastTechExp = 110005,  -- 东北科技经验
	NorthChinaTechExp = 110006,  -- 华北科技经验
	EastChinaTechExp = 110007,  -- 华东科技经验
	CentralchinaTechExp = 110008,  -- 华中科技经验
	NorthwestTechExp = 110009,  -- 西北科技经验
	SouthwestTechExp = 110010,  -- 西南科技经验
	SouthChinaTechExp = 110011,  -- 华南科技经验

}


ExploerRegion = {
	Northeast = 1,  --东北
	NorthChina = 2, --华北
	EastChina = 3, --华东
	CentralChina = 4, --华中
	Northwest = 5, --西北
	Southwest = 6, --西南
	SouthChina = 7, --华南
}

-- hotel类型
HotelType = {
	Hotel_first_floor_reward = 1,  -- 1层奖励
	Hotel_second_floor_reward = 2,   -- 2层奖励
	Hotel_shop = 3,    -- 商店
	Hotel_reborn = 4,   -- 复活
	Hotel_recover = 5,   -- 恢复
	Hotel_boss = 6,   -- boss
	Hotel_elite = 7,   -- 精英怪
	Hotel_normal = 8,   -- 普通怪
	Hotel_none = 0,  -- 无
}

RedPointType = {
	AllMail = 1,
	Mail = 2,
	TopRight = 3,
	AllFriendRequest = 4,
	FriendRequest = 5,
}
-- buff系统
BuffSystem = {
	Illustrated = 1,
	ExploreFight = 3,
	Hotel = 4,
}
--系统buff涉及的系统类型
BuffSystemType = {
	fight = 1,
	explore = 2,
	hangUp = 3,
	home = 4,
	task = 5,
	library = 6,

}

TaskTag = {
	Adventure = 1,
	Endless = 2,
	PetLevelUp = 3,
	ArenaRank = 4,
	PetCount = 5,
	JoinGuild = 6,
	FriendsCount = 7,
	PetFavorability = 8,
	RecruitCount = 11,
	CostDiamond = 12,
	ReceiveHangingRewardCount = 13,
	BountyTaskCompleted = 14,
	ConsumeStrength = 15,
	ChallengeArenaCount = 16,
	LoginCount = 17,
	PetInteractionCount = 18,
	PlayPuzzleCount = 19,
	GetPets = 31,
	PetEvolution = 32,
	PetIntimacy = 33,
	GetFood = 41,
	GetSouvenir = 51,
}

BuffType = {
	hp = 1, -- 生命
	atc = 2,  --攻击
	physicalDefense = 3,  -- 物理防御
	magicDefense = 4, --魔法防御
	rating = 5, --命中率
	crit = 6, --暴击率
	decrit = 7,  --抗暴率
	criticalDamage =8, --暴击伤害
	doge = 9, --闪避率
	pveDamageUp = 10,  --pve伤害加成
	pveDamageDown = 11,  --pve伤害减免
	pvpDamageUp = 12,  --pvp伤害加成
	pvpDamageDown = 13,  --pvp伤害减免
	physicalDefenseIgnore = 14,  --物防忽视
	magicDefenseIgnore = 15,  -- 法防忽视
	immuneControl = 16,  --免控率

	exploreSpeed = 17,  -- 探索速度
	exploreExperienceYield = 18,  --探索经验产量
	exploreItemYieldAdd = 19,   --探索获得某种道具产量增加
	eventSixDepDrop = 20, --事件六维判定值下降
	waterAdd = 21,  --水六唯增加
	fireAdd = 22, --火六唯增加
	woodAdd = 23, --木六唯增加
	soilAdd = 24, --土六唯增加
	windAdd = 25, --风六唯增加
	thunderAdd = 26, --雷六唯增加

	hangUpGold = 27, -- 挂机金币增加
	hangUpExp = 28, -- 挂机经验增加
	hangUpPlayerExp = 29, -- 挂机主角经验增加

	sendGiftAddFriendly = 30, --赠送礼品额外增加亲密度
	homeHeartOutputAdd = 31, --公寓爱心产出速度

	dailyTaskRewardAdd = 32,  --日常任务奖励额外增加积分
	weeklyTaskRewardAdd = 33,  --周常任务奖励额外增加积分
	bountyTaskGoldAdd = 34,  --赏金任务额外增加金币
	bountyTaskSpeedAdd = 35,  --赏金任务完成速度加成

	libraryFoodIncomeAdd = 36, --展览馆美食每日收入增加
	librarySouvenirIncomeAdd = 37,  --展览馆纪念品每日收入增加
	libraryPostcardIncomeAdd = 38,  --展览馆明信片每日收入增加
}

MsgType =
{
	--私聊
	private = 1,
	--全部服务器
	allServer = 2,
	--单独服务器
	singleServer = 3,

	guild = 4,
}

ChatTopicType =
{
	private = "chat_topic_private_",
	allServer = "chat_topic_all_server",
	singleServer = "chat_topic_single_server_",
	guild = "chat_topic_guild_",
	serverCall = "server_call_",
}

PetPosScore = {
	[1] = {[1] = 9000, [2] = 9000,  [3] = 10000, [4] = 6000,  [5]= 6000,  [6]= 6000,  first = {3},},
	[2] = {[1] = 10000,[2] = 10000, [3] = 10000, [4] = 3000,  [5]= 3000,  [6]= 3000,  first = {1,2},},
	[3] = {[1] = 3000, [2] = 3000,  [3] = 3000,  [4] = 10000, [5]= 12000, [6]= 8000,  first = {4,5},},
	[4] = {[1] = 5000, [2] = 5000,  [3] = 4000,  [4] = 8000,  [5]= 6000,  [6]= 10000, first = {6},},
}

--进攻方 萌宠站位pos
RoundAttPos = {
    [1] = {
        x = -1.6,
        y = 0.1,
        z = -2.35,
    },
    [2] = {
        x = 0,
        y = 0.1,
        z = -2.35,
    },
    [3] = {
        x = 1.6,
        y = 0.1,
        z = -2.35,
    },
    [4] = {
        x = -1.6,
        y = 0.1,
        z = -4.64,
    },
    [5] = {
        x = 0,
        y = 0.1,
        z = -4.64,
    },
    [6] = {
        x = 1.6,
        y = 0.1,
        z = -4.64,
    }
}
--防守方 萌宠站位pos
RoundDefPos = {
    [1] = {
        x = -1.6,
        y = 0.1,
        z = 2.49,
    },
    [2] = {
        x = 0,
        y = 0.1,
        z = 2.49,
    },
    [3] = {
        x = 1.6,
        y = 0.1,
        z = 2.49,
    },
    [4] = {
        x = -1.6,
        y = 0.1,
        z = 4.87,
    },
    [5] = {
        x = 0,
        y = 0.1,
        z = 4.87,
    },
    [6] = {
        x = 1.6,
        y = 0.1,
        z = 4.87,
    }
}
--布阵摄像机
MainCameraPos = {
        x = 0,
        y = 10.88,
        z = -3.2,
    }
MainCameraRot = {
        x = 90,
        y = 0,
        z = 0,
    }
--战斗摄像机  初始位
MainCameraBatPos = {
        x = 0.61,
        y = 5.46,
        z = -8.07,
    }
MainCameraBatRot = {
        x = 39.97,
        y = -7.37,
        z = -1.305,
    }


-- 回合中 摄像机位
MainCameraPetTurnPos = {
	[1] = {
        x = 0.61,
        y = 5.46,
        z = -8.07,
    },
    [2] = { 
       x = 0.61,
        y = 5.46,
        z = -8.07,
    },
    [3] = { 
        x = 0.61,
        y = 5.46,
        z = -8.07,
    },
    [4] = {
        x = 0.61,
        y = 5.46,
        z = -8.07,
    },
    [5] = {
       x = 0.61,
        y = 5.46,
        z = -8.07,
    },
    [6] = {
        x = 0.61,
        y = 5.46,
        z = -8.07,
    }
}
MainCameraPetTurnRot = {
	[1] = {
        x = 39.97,
        y = -7.37,
        z = -1.305,
    },
    [2] = {
        x = 39.97,
        y = -7.37,
        z = -1.305,
    },
    [3] = {
        x = 39.97,
        y = -7.37,
        z = -1.305,
    },
    [4] = {
        x = 39.97,
        y = -7.37,
        z = -1.305,
    },
    [5] = {
         x = 39.97,
        y = -7.37,
        z = -1.305,
    },
    [6] = {
         x = 39.97,
        y = -7.37,
        z = -1.305,
    }
}
-- 特写 摄像机位
MainCameraAttPetNivPos = {
	[1] = {
        x = -1.01,
        y = 3.55,
        z = -4.51,
    },
    [2] = { 
        x = 0.63,
        y = 3.34,
        z = -4.24,
    },
    [3] = {
        x = 1.98,
        y = 3.39,
        z = -4.56,
    },
    [4] = {
        x = -1.1,
        y = 3.51,
        z = -6.29,
    },
    [5] = {
        x = 0.57,
        y = 3.63,
        z = -6.73,
    },
    [6] = {
        x = 2.08,
        y = 3.38,
        z = -6.41,
    }
}
MainCameraAttPetNivRot = {
	[1] = { 
        x = 37.12906,
        y = -14.46283,
        z = -3.570129,
    },
    [2] = {
        x = 37.12906,
        y = -14.46283,
        z = -3.570129,
    },
    [3] = {
        x = 39.06133,
        y = -9.020081,
        z = -2.51004,
    },
    [4] = { 
        x = 42.23502,
        y = -9.207916,
        z = -2.632446,
    },
    [5] = {
        x = 36.72586,
        y = -10.53366,
        z = -7.576843,
    },
    [6] = {
        x = 35.86231,
        y = -7.84552,
        z = -3.134369,
    }
}
MainCameraDefPetNivPos = {
	[1] = { 
        x = -0.9,
        y = 3.5,
        z = -2.59,
    },
    [2] = {
        x = 0.84,
        y = 3.72,
        z = -2.5,
    },
    [3] = {
        x = 2.02,
        y = 4.16,
        z = -2.81,
    },
    [4] = {
        x = 0.12,
        y = 4.81,
        z = -1.88,
    },
    [5] = { 
        x = 1.21,
        y = 4.18,
        z = -1.47,
    },
    [6] = {
        x = 3.04,
        y = 4.3,
        z = -1.48,
    }
}
MainCameraDefPetNivRot = {
	[1] = { 
        x = 37.12906,
        y = -14.46283,
        z = -3.570129,
    },
    [2] = {
        x = 38.91716,
        y = -14.6062,
        z = -3.658447,
    },
    [3] = {
        x = 42.23502,
        y = -9.207916,
        z = -2.632446,
    },
    [4] = {
        x = 40.76313,
        y = -23.97299,
        z = -0.8170776,
    },
    [5] = {
        x = 36.1246,
        y = -17.53485,
        z = -0.9399414,
    },
    [6] = {
        x = 34.27035,
        y = -22.70007,
        z = -2.495209,
    }
}

